package com.advm.bean;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.advm.dao.VideoDAO;

public class PageBean {
	
	public PageBean(){	
	}
	public VideoDAO dao;
	

	// 根据传入的当前页数，每页的显示的页数，显示要查询的数据
	public List<ADInfo> fenYe(int countPage, int mayPage) throws SQLException {
		dao = new VideoDAO();
		List<ADInfo> list = new ArrayList<ADInfo>();
		list = dao.getPageADItems(countPage, mayPage);
		return list;
	}

	// 查询总的记录数
	public int sumPage() throws SQLException {
		dao = new VideoDAO();
		return dao.getCountADItems();
	}

	// 查询总页数
	public int sumPageCount(int pageCount) throws SQLException {
		int sumPageCount = 0;
		int sumPage = this.sumPage();
		// 如果总的数据数%每页显示数整除的话，就去取整数；否则就把总页数加1
		if (sumPage % pageCount == 0) {
			sumPageCount = sumPage / pageCount;
		} else {
			sumPageCount = sumPage / pageCount + 1;
		}
		return sumPageCount;
	}
}
